package com.fms.gui.templateCreator.components.date.parts;

import junit.framework.TestCase;

import org.jmock.Expectations;
import org.jmock.Mockery;

import com.fms.TestUtils;
import com.fms.gui.templateCreator.components.date.ITimeInformer;
import com.fms.gui.templateCreator.components.date.parts.HourHand;

public class HourHandTest extends TestCase
{
	Mockery mock;
	
	
	public void setUp()
	{
		mock = new Mockery();
	}
	
	public void tearDown()
	{
		mock.assertIsSatisfied();
	}
	
	
	
	public void testHourHandNoon()
	{		
		final ITimeInformer informer = mock.mock(ITimeInformer.class);
		
		mock.checking(new Expectations() 
		{{
			oneOf(informer).getHour(); will(returnValue(0));
			oneOf(informer).getMinute(); will(returnValue(0));
		}});
		
		HourHand hand = new HourHand(informer);		
		assertTrue(TestUtils.aboutEqual(hand.getAngle(), 0.0));		
	}
	
	public void testHourHandOneThirty()
	{		
		final ITimeInformer informer = mock.mock(ITimeInformer.class);
		
		mock.checking(new Expectations() 
		{{
			oneOf(informer).getHour(); will(returnValue(1));
			oneOf(informer).getMinute(); will(returnValue(30));
		}});
		
		HourHand hand = new HourHand(informer);		
		assertTrue(TestUtils.aboutEqual(hand.getAngle(), Math.PI/4.0));		
	}
	
	public void testHourHandSixOclock()
	{		
		final ITimeInformer informer = mock.mock(ITimeInformer.class);
		
		mock.checking(new Expectations() 
		{{
			oneOf(informer).getHour(); will(returnValue(6));
			oneOf(informer).getMinute(); will(returnValue(0));
		}});
		
		HourHand hand = new HourHand(informer);		
		assertTrue(TestUtils.aboutEqual(hand.getAngle(), Math.PI));		
	}
	
	public void testHourHandNineOClock()
	{		
		final ITimeInformer informer = mock.mock(ITimeInformer.class);
		
		mock.checking(new Expectations() 
		{{
			oneOf(informer).getHour(); will(returnValue(9));
			oneOf(informer).getMinute(); will(returnValue(0));
		}});
		
		HourHand hand = new HourHand(informer);		
		assertTrue(TestUtils.aboutEqual(hand.getAngle(), Math.PI * 3.0/2.0));		
	}
}
